﻿@{
    Layout = "_LayoutBody";
}
<div class="pagebox" id="pageContentId">
    <div class="home-desktop">
        <div class="condition-box">
            <div class="condition-items">
                <span class="condition-title">CAS代码：</span><input type="text" id="txt_casNo" class="condition-txt">
                <span class="condition-title">中文名：</span><input type="text" id="txt_cName" class="condition-txt">
                <span class="condition-title">英文名：</span><input type="text" id="txt_eName" class="condition-txt">
            </div>
            <div class="condition-items">
                <button type="button" class="cotrlBtn btnBlue" id="btn_search"><i class="icon-search"></i>&nbsp;查询</button>
            </div>
            <div class="clear"></div>
        </div>
        <div class="area">
            <!--内容列表开始-->
            <table class="data" cellpadding="0" cellspacing="0" id="basicIngredient_table" style="table-layout:auto;">
                <thead>
                    <tr>
                        <th class="text-left" style="width: 60px;">
                            <label for="checkall">
                                <input id="checkall" type="checkbox" class="group-checkable check-item" data-set="#basicIngredient_table .check-item" />全选
                            </label>
                        </th>
                        <th>CAS代码</th>
                        <th>EC代码</th>
                        <th>中文名</th>
                        <th>英文名</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
            <!--内容列表结束-->
            <!--分页-->
            <div class="pages">
                <div class="left">
                </div>
                <div id="primarykeypage" class="right pageDiv text-right">
                </div>
            </div>
            <!--分页结束-->
        </div>
    </div>
    <!--列表双击效果-->
</div>

<script id="temp_basicIngredient" type="text/html">
    <!--总行数-->
    <input type="hidden" id="page_total" value="{{data.totalCount}}" />
    {{if  data.items!=null && data.items!="" && data.items!=undefined && data.items.length>0 }}
    {{each data.items as item i}}
    <tr id="{{item.id}}">
        <td class="text-left">
            <label>
                <span>
                    <input type="checkbox" class="check-item" value="{{item.casNo}}|{{item.cName}}">
                </span>
            </label>
        </td>
        <td>{{item.casNo}}</td>
        <td>{{item.ecNo}}</td>
        <td>{{item.cName}}</td>
        <td>{{item.eName}}</td>
    </tr>
    {{/each}}
    {{else}}
    <tr class="lastrow">
        <td colspan="9">
            <label>暂无数据</label>
        </td>
    </tr>
    {{/if}}
</script>
<script type="text/javascript">
    var pageObj = new Pager({ params: { "casNo": "txt_casNo", "cName": "txt_cName", "eName": "txt_eName"} }, {
        url: "@Url.Action("Search")",
        obj: $('#primarykeypage'),
        autoLoad: true
    }, function (json) {
            var html = template('temp_basicIngredient', JSON.parse(json));
            $('#basicIngredient_table').find("tbody").html(html);
            GroupCheckable_Change("basicIngredient_table");
        $(".dataTabs-ctrol-down").on("click", ".dataTabs-ctrol-btn", function () {
            var _this = $(this);
            if ($(this).hasClass("curr")) {
                $(this).removeClass("curr");
                $(this).closest('.dataTabs-ctrol-down').find('.dataTabs-ctrol-info').slideUp(100);
                $(this).find('i').rotate(0);
            } else {
                $(this).addClass("curr");
                $(this).closest('.dataTabs-ctrol-down').find('.dataTabs-ctrol-info').slideDown(100);
                $(this).find('i').rotate(180);
                $(this).closest('tr').siblings("tr").find('.dataTabs-ctrol-info').slideUp(100);
                $(this).closest('tr').siblings("tr").find('.dataTabs-ctrol-btn').removeClass("curr");
                $(this).closest('tr').siblings("tr").find('.dataTabs-ctrol-btn').find('i').rotate(0);
            }
            $("body").unbind("click").one("click", function () {
                _this.removeClass("curr");
                _this.closest('.dataTabs-ctrol-down').find('.dataTabs-ctrol-info').slideUp(100);
                _this.find('i').rotate(0);
            });
            return false;
        });
        $(".dataTabs-ctrol-down").on("click", ".dataTabs-ctrol-info", function (e) {
            e.stopPropagation();
        });
    });
    // 查询按钮单击事件
    function btn_search_click() {
        pageObj.moveFirst();
    }
    // 查询按钮单击事件
    $("#btn_search").click(function () {
        btn_search_click();
    });

    //选择回调
    var callbackdata = function () {
        //获取选中的值
        var rows = GetSelectRowOfCheckbox('basicIngredient_table', 0, true);
        return rows;
    }
</script>
